package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RentalSysPaymentRecords;
import com.ruoyi.system.service.IRentalSysPaymentRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支付记录Controller
 *
 * @author Mag1c_-xyy
 * @date 2024-04-21
 */
@RestController
@RequestMapping("/system/paymentRecords")
public class RentalSysPaymentRecordsController extends BaseController
{
    @Autowired
    private IRentalSysPaymentRecordsService rentalSysPaymentRecordsService;

    /**
     * 查询支付记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:paymentRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(RentalSysPaymentRecords rentalSysPaymentRecords)
    {
        startPage();
        List<RentalSysPaymentRecords> list = rentalSysPaymentRecordsService.selectRentalSysPaymentRecordsList(rentalSysPaymentRecords);
        return getDataTable(list);
    }

    /**
     * 导出支付记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:paymentRecords:export')")
    @Log(title = "支付记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RentalSysPaymentRecords rentalSysPaymentRecords)
    {
        List<RentalSysPaymentRecords> list = rentalSysPaymentRecordsService.selectRentalSysPaymentRecordsList(rentalSysPaymentRecords);
        ExcelUtil<RentalSysPaymentRecords> util = new ExcelUtil<RentalSysPaymentRecords>(RentalSysPaymentRecords.class);
        util.exportExcel(response, list, "支付记录数据");
    }

    /**
     * 获取支付记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:paymentRecords:query')")
    @GetMapping(value = "/{paymentId}")
    public AjaxResult getInfo(@PathVariable("paymentId") Long paymentId)
    {
        return success(rentalSysPaymentRecordsService.selectRentalSysPaymentRecordsByPaymentId(paymentId));
    }

    /**
     * 新增支付记录
     */
    @PreAuthorize("@ss.hasPermi('system:paymentRecords:add')")
    @Log(title = "支付记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RentalSysPaymentRecords rentalSysPaymentRecords)
    {
        return toAjax(rentalSysPaymentRecordsService.insertRentalSysPaymentRecords(rentalSysPaymentRecords));
    }

    /**
     * 修改支付记录
     */
    @PreAuthorize("@ss.hasPermi('system:paymentRecords:edit')")
    @Log(title = "支付记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RentalSysPaymentRecords rentalSysPaymentRecords)
    {
        return toAjax(rentalSysPaymentRecordsService.updateRentalSysPaymentRecords(rentalSysPaymentRecords));
    }

    /**
     * 删除支付记录
     */
    @PreAuthorize("@ss.hasPermi('system:paymentRecords:remove')")
    @Log(title = "支付记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{paymentIds}")
    public AjaxResult remove(@PathVariable Long[] paymentIds)
    {
        return toAjax(rentalSysPaymentRecordsService.deleteRentalSysPaymentRecordsByPaymentIds(paymentIds));
    }
}
